<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>文章列表</title>
</head>
<body>

<!--{include file='comm/naviBanner.tpl'}-->

<div class="container">

    <!--{include file='comm/menu.tpl'}-->

    <div class="comm_crub">
        <span class="now_crub">文章列表</span>
    </div>

    <div class="comm_content">

            <div class="search-box">
                <div style="position:relative">
                    <form id="search_form" onsubmit="return false;">
                        <table>
                            <tbody>
                            <tr>
                                <td>
                                    <span>
                                        文章分类：<select id="article_category_id" name="article_category_id" size="1" style="width:160px;">
                                            <option value="">请选择</option>
                                            <!--{foreach from=$category_array item=line}-->
                                                <option value="<!--{$line.category_id}-->"><!--{$line.category_title}--></option>
                                            <!--{/foreach}-->
                                        </select>
                                    </span>
                                    <span>文章标题：<input type="text" id="article_title" name="article_title" value="" /></span>
                                    <span><input type="button" value="查询" class="btn" onclick="article.search();" /></span>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>

            <table id="flex" style="display:none"></table>

        </div>


</div>

<script type="text/javascript">
    $("#flex").flexigrid({
        url:"/invokingAjax-backend/content/article.ajax?operFlg=3",
        dataType: "json",
        colModel : [
            {display: "操作", width : 120, align: "center"},
            {display: "文章编号", name : "article_id", width : 100, sortable : true},
            {display: "文章标题", width : 260},
            {display: "文章分类", width : 200},
            {display: "文章摘要", width : 300},
            {display: "使用标志", width : 70, align: "center"}
        ],
        buttons : [
            {name: "添加", bclass: "add", onpress : "article.add"},
            {separator: true},
            {name: "删除", bclass: "delete", onpress : "article.deleteArticle"}
        ],
        sortname: "article_id",
        sortorder: "desc",
        usepager: true,
        rp: 10,
        useRp: true,
        showTableToggleBtn: true,
        onSubmit: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt});
            return true;
        }
    });

    var article = {

        delete_str: "",

        //搜索文章
        search: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt}).flexReload();
        },

        //添加文章
        add: function() {
            E.open("/quanliadmin/app/content/article.pscript?operFlg=5", "", {height: 600,width: 1024, top: 50, left: 150});
        },

        deleteArticle: function() {
            this.delete_str = "";
            $.each($("#flex").find("tr"), function(k, v) {
                if ($(v).hasClass("trSelected")) {
                    article.delete_str += "_" + $(v).attr("id").replace("row", "");
                }
            });

            if (this.delete_str == "")
                E.alert("请选择删除文章");
            else
                E.confirm("您确认要删除选中的文章吗？", "article.deleteConfirm");
        },

        deleteConfirm: function() {
            this.delete_str = this.delete_str.substr(1);
            $.ajax({
                type: "POST",
                url: "/invokingAjax-backend/content/article.ajax?operFlg=7&delete_str=" + article.delete_str,
                dataType: "JSON",
                success: function( result_obj ) {
                    if (result_obj.code == 200) {
                        E.alert(result_obj.message, 2, "article.load");
                    } else {
                        E.alert(result_obj.message);
                    }
                }
            });
        },

        edit: function(article_id) {
            E.open("/quanliadmin/app/content/article.pscript?operFlg=6&article_id=" + article_id, "", {height: 600,width: 1024, top: 50, left: 150});
        },

        load: function() {
            $("#flex").flexReload();
        },

        change_status: function(status) {

        }

    };
</script>


</body>
</html>